<?php

function smarty_function_getuser_sale_by_uid($params, &$smarty) {
    //Get value from page
    $uid = $params['uid'];
    if($uid){
      //Query data
      $sql = "SELECT
                COUNT(tpc_id) 'count_sale' 
              FROM
                zk_innoforum_topics 
              WHERE
                tpc_type_id = 3
              AND
                tpc_cr_uid = ".$uid;

      $column = array("count_sale");
      $result = DBUtil::executeSQL($sql);
      $objectArray = DBUtil::marshallObjects ($result, $column);
      $saleNo = $objectArray['0']['count_sale'];
    }else{
      $saleNo= "";
    }

    return $saleNo;
}